package com.byron.pss.util;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import com.byron.pss.domain.LostFound;
import com.byron.pss.domain.LostFoundStr;

/**
 * 转化工具类
 * @author Byron
 *
 */
public class Transform {

	private Transform() {
	}

	/**
	 * 将遗失物品信息的日期转化成字符串形式，提供给jsp使用
	 * @param lf 待转化的实体
	 * @return 转化后的实体
	 */
	public static LostFoundStr trsLostFound0str(LostFound lf) {
		LostFoundStr lfstr = new LostFoundStr();
		lfstr.setId(lf.getId());
		lfstr.setName(lf.getName());
		lfstr.setDescribe(lf.getDescribe());
		lfstr.setLocation(lf.getLocation());
		
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		String lostTime = sf.format(lf.getLostTime());
		lfstr.setLostTime(lostTime);
		
		lfstr.setNumber(lf.getNumber());
		lfstr.setOther(lf.getOther());
		return lfstr;
	}
	
	/**
	 * 专门供jsp展示用的
	 * @return
	 */
	public static List<LostFoundStr> list0jsp(List<LostFound> list) {
		List<LostFoundStr> lists = new ArrayList<>();
		for (LostFound lostFound : list) {
			LostFoundStr lfstr = Transform.trsLostFound0str(lostFound);
			lists.add(lfstr);
		}
		return lists;
	}
}
